#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time    : 2021/4/21 15:42
# @Author  : sunjing
# @Site    : 
# @File    : search_form.py
# @Software: PyCharm
from django.http import HttpResponse
from django.shortcuts import render


# 表单文件的位置
def search_form(request):
    return render(request, 'search_form.html')


# 从get结束请求
def search2(request):
    request.encoding = 'utf-8'
    if 'q' in request.GET and request.GET['q']:  # q是文本框中输入的
        message = '你搜索的内容为:' + request.GET['q']
    else:
        message = '你提交了空表单'
    return HttpResponse(message)


def search_post(request):
    res = {}
    if request.POST:
        res['result'] = request.POST['q']

    return render(request, 'post_form.html', res)
